﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Jb.Common.Extensions;
using Jb.Domain;
using Jb.Web.ViewModels;
using Jb.Web.Utility;
using AutoMapper;

namespace Jb.Web.Areas.Private.Controllers
{
    [Authorize(Roles = "Company Admin,Company User,Job Seeker,Admin")]
    public class AccountController : BaseController
    {
		private JbEntities _Context = new JbEntities();
        
		#region Constructors
		public AccountController()
		{
		}

		public AccountController(UserViewModel currentUser)
			: base(currentUser)
        {
        }
		#endregion Constructors

		#region Action Methods
        public ActionResult Index()
        {
            return RedirectToAction("dashboard");
        }
        public ActionResult DashBoard()
        {
            if (UserInfo.IsAdmin)
                return RedirectToAction("Dashboard", "Account", new { area = AppConstants.Area.ADMIN });
            else if (UserInfo.IsJobSeeker)
                return RedirectToAction("Dashboard", "Account", new {area = AppConstants.Area.JOB_SEEKER});
            else
            {                
                Company company = _Context.GetCompanyByID(LoggedInUser.Contact.CompanyID);
                CompanyViewModel viewModel = Mapper.Map<CompanyViewModel>(company);
                return View(viewModel);
            }
        }		
		#endregion Action Methods
		
		#region Helper Methods

        #endregion			
    }
}
